A bunch of mechanical NEW_STRING cleanups, pencil whipping code
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 7 Apr 2014 02:54:07 +0000 (02:54 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 7 Apr 2014 02:54:07 +0000 (02:54 +0000)
against replacements..

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4796 f51c46e8-681c-474f-0cfe-069cfd0219fb

21 files changed:
gpsbabel/bcr.cc
gpsbabel/csv_util.cc
gpsbabel/exif.cc
gpsbabel/g7towin.cc
gpsbabel/garmin.cc
gpsbabel/garmin_tables.cc
gpsbabel/ggv_ovl.cc
gpsbabel/gpx.cc
gpsbabel/gtrnctr.cc
gpsbabel/humminbird.cc
gpsbabel/kml.cc
gpsbabel/magproto.cc
gpsbabel/mapsend.cc
gpsbabel/mtk_logger.cc
gpsbabel/osm.cc
gpsbabel/pcx.cc
gpsbabel/psitrex.cc
gpsbabel/skytraq.cc
gpsbabel/stmsdf.cc
gpsbabel/tiger.cc
gpsbabel/util.cc

index d2de9dada580acf9564306f72d50d7dd6cf90121..d1e2347176c54a2fe7c4388c84dd8bca94cdf828 100644 (file)
@@ -492,7 +492,6 @@ bcr_route_header(const route_head* route)
 
   bcr_write_line(fout, "[ROUTE]", NULL, NULL);         /* route section */
 
-//  xasprintf(&sout, "%d,%d,%d,%d", emin, nmax, emax, nmin);
   sout = QString::number(emin) + "," +
          QString::number(nmax) + "," +
          QString::number(emax) + "," +
index 4554ca0b6e9c09dd980f21809586be0957687abd..df44a5cc942f3f6ac04e182daa3a29dced855c58 100644 (file)
@@ -175,45 +175,6 @@ static UrlLink* link_;
 /*     usage: p = csv_stringclean(stringtoclean, "&,\"")             */
 /*            (strip out ampersands, commas, and quotes.             */
 /*********************************************************************/
-#if 0
-char*
-#ifdef DEBUG_MEM
-CSV_STRINGCLEAN(const char* string, const char* chararray, DEBUG_PARAMS)
-#else
-csv_stringclean(const char* string, const char* chararray)
-#endif
-{
-  char* p1;
-  char* p2;
-  const char* cp;
-  char* tmp = xxstrdup(string,file,line);
-
-  if ((! string) || (! chararray)) {
-    return (tmp);
-  }
-
-  /* p2 - end of the original string */
-  p2 = tmp + strlen(tmp);
-
-  cp = chararray;
-
-  while (*cp) {
-    p1 = tmp;
-    while (*p1) {
-      if (*cp == *p1) {
-        /* we don't want this character! */
-        memmove(p1, p1 + 1, (p2 - p1));
-        p1[p2 - p1] = '\0';
-        p2--;
-      } else {
-        p1++;
-      }
-    }
-    cp++;
-  }
-  return (tmp);
-}
-#else
 // Implement the C version via Qt - the reverse of most of our shims.
 char*
 csv_stringclean(const char* source, const char* chararray)
@@ -222,7 +183,6 @@ csv_stringclean(const char* source, const char* chararray)
   QString cleansed(csv_stringclean(QString(source), chararray));
   return xstrdup(cleansed);
 }
-#endif
 
 QString
 csv_stringclean(const QString& source, const QString& to_nuke)
@@ -232,17 +192,12 @@ csv_stringclean(const QString& source, const QString& to_nuke)
   return r.remove(QRegExp(regex));
 }
 
-/***********************************************************************************/
-/* csv_stringtrim() - trim whitespace and leading and trailing enclosures (quotes) */
-/*                    returns a copy of the modified string                        */
-/*    usage: p = csv_stringtrim(string, "\"", 0)                                   */
-/***********************************************************************************/
+// csv_stringtrim() - trim whitespace and leading and trailing 
+//                    enclosures (quotes) 
+//                    returns a copy of the modified string
+//    usage: p = csv_stringtrim(string, "\"", 0)
 char*
-#ifdef DEBUG_MEM
-CSV_STRINGTRIM(const char* string, const char* enclosure, int strip_max, DEBUG_PARAMS)
-#else
 csv_stringtrim(const char* string, const char* enclosure, int strip_max)
-#endif
 {
   static const char* p1 = NULL;
   char* p2 = NULL;
@@ -1724,7 +1679,7 @@ xcsv_waypt_pr(const Waypoint* wpt)
         UrlLink l = wpt->GetUrlLink();
         buff += QString().sprintf(fmp->printfc, CSTR(l.url_));
       } else {
-        buff += QString().sprintf(fmp->val && *fmp->val ? fmp->val : "\"\"");
+        buff += QString().sprintf(fmp->printfc, fmp->val && *fmp->val ? fmp->val : "\"\"");
       }
     }
     break;
index fbb47313159e0362f5c289bb07bdc490426ca8bc..6181d266996c085dabfc29ec534a4e59ae46f05b 100644 (file)
@@ -212,19 +212,19 @@ exif_type_size(const uint16_t type)
   return size;
 }
 
-static char*
+// TODO: If this were actually ever used (!?!?!) it could probably be 
+// replaced by return QDateTime(time).toString("yyyy/MM/dd, hh:mm:ss);
+static QString
 exif_time_str(const time_t time)
 {
   struct tm tm;
-  char* res;
 
   tm = *localtime(&time);
   tm.tm_year += 1900;
   tm.tm_mon += 1;
-  xasprintf(&res, "%04d/%02d/%02d, %02d:%02d:%02d",
-            tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
 
-  return res;
+  return QString().sprintf("%04d/%02d/%02d, %02d:%02d:%02d",
+         tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
 }
 
 static char*
@@ -1396,7 +1396,7 @@ exif_wr_init(const char* fname)
   if (exif_time_ref == 0) {
     fatal(MYNAME ": No valid timestamp found in picture!\n");
   }
-
+abort();
   xasprintf(&tmpname, "%s.jpg", fname);
   fout = gbfopen_be(tmpname, "wb", MYNAME);
   xfree(tmpname);
@@ -1443,7 +1443,7 @@ exif_write(void)
       warning(MYNAME ": No matching point with name \"%s\" found.\n", opt_name);
     }
   } else {
-    char* str = exif_time_str(exif_time_ref);
+    QString str = exif_time_str(exif_time_ref);
 
     track_disp_all(NULL, NULL, exif_find_wpt_by_time);
     route_disp_all(NULL, NULL, exif_find_wpt_by_time);
@@ -1454,16 +1454,14 @@ exif_write(void)
     if (exif_wpt_ref == NULL) {
       warning(MYNAME ": No point with a valid timestamp found.\n");
     } else if (abs(exif_time_ref - exif_wpt_ref->creation_time.toTime_t()) > frame) {
-      warning(MYNAME ": No matching point found for image date %s!\n", str);
+      warning(MYNAME ": No matching point found for image date %s!\n", CSTR(str));
       if (exif_wpt_ref != NULL) {
-        char* str = exif_time_str(exif_wpt_ref->creation_time.toTime_t());
+        QString str = exif_time_str(exif_wpt_ref->creation_time.toTime_t());
         warning(MYNAME ": Best is from %s, %d second(s) away.\n",
-                str, abs(exif_time_ref - exif_wpt_ref->creation_time.toTime_t()));
-        xfree(str);
+                CSTR(str), abs(exif_time_ref - exif_wpt_ref->creation_time.toTime_t()));
       }
       exif_wpt_ref = NULL;
     }
-    xfree(str);
   }
 
   if (exif_wpt_ref != NULL) {
index 3c1ee51a0c9c3353d1e2c65a294c88a6a6e78618..e2f13e263295954a4417890fdff8b1950690bc4c 100644 (file)
@@ -462,7 +462,7 @@ data_read(void)
       wpt = new Waypoint;
       cdata += parse_coordinates(cdata, datum, grid,
                                  &wpt->latitude, &wpt->longitude, MYNAME);
-      xasprintf(&wpt->shortname, "Event%d", ++event_ct);
+      wpt->shortname = QString("Event%1").arg(++event_ct);
       while (isspace(*cdata)) {
         cdata++;
       }
index b264e69f986c7749345cd4334216224fcd6dfd70..a77a0233e5adb5b5480d2b5e71def14594790d9d 100644 (file)
@@ -945,9 +945,6 @@ waypoint_prepare(void)
     } else {
       if (global_opts.smart_names &&
           wpt->gc_data->diff && wpt->gc_data->terr) {
-#if 0
-        xasprintf(&src, "%s %s", &wpt->shortname[2], src);
-#endif
         snprintf(obuf, sizeof(obuf), "%s%d/%d %s",
                  get_gc_info(wpt),
                  wpt->gc_data->diff, wpt->gc_data->terr,
index ed041438e10d8d90e009a7fca5d0bcf38021b0c3..3bd09f0e9c8818f0b26a02bc6809c20ca46af54c 100644 (file)
@@ -1025,10 +1025,8 @@ gt_lookup_datum_index(const char* datum_str, const char* module)
   result = GPS_Lookup_Datum_Index(name);
 
   if (result < 0) {
-    char* tmp;
-    xasprintf(&tmp, "%s mean", datum_str);
-    result = GPS_Lookup_Datum_Index(tmp);
-    xfree(tmp);
+    QString tmp = QString(datum_str) + " mean";
+    result = GPS_Lookup_Datum_Index(CSTR(tmp));
   }
 
   is_fatal(result < 0,
index 80318bf52c8ccf2395cbf83c8d8a1bee9ba9cacb..2de58a82c25cb81c76a4a60d27f8fe6003743b56 100644 (file)
@@ -137,11 +137,11 @@ ggv_ovl_read(void)
         if (group > 1) {
           route_add_head(rte);
           route_ct++;
-          xasprintf(&rte->rte_name, "Route %d", route_ct);
+            trk->rte_name = QString("Route %1").arg(route_ct);
         } else {
           track_add_head(trk);
           track_ct++;
-          xasprintf(&trk->rte_name, "Track %d", track_ct);
+            trk->rte_name = QString("Track %1").arg(track_ct);
         }
 
         for (j = 0; j < points; j++) {
index 20dc6c772a65f39f19d1aa57a088927370d27b5e..f066cf2c3b468e1b210ae483fadf1399a80d0f97 100644 (file)
@@ -1524,11 +1524,7 @@ gpx_write_common_description(const Waypoint* waypointp, QString oname)
   writer->writeOptionalTextElement("name", oname);
 
   writer->writeOptionalTextElement("cmt", waypointp->description);
-#if NEW_STRINGS
   if (!waypointp->notes.isEmpty()) {
-#else
-  if (waypointp->notes && waypointp->notes[0]) {
-#endif
     writer->writeTextElement("desc", waypointp->notes);
   } else {
     writer->writeOptionalTextElement("desc", waypointp->description);
@@ -1582,13 +1578,9 @@ gpx_track_hdr(const route_head* rte)
   current_trk_head = rte;
 
   writer->writeStartElement("trk");
-#if NEW_STRINGS 
   writer->writeOptionalTextElement("name", rte->rte_name);
   writer->writeOptionalTextElement("desc", rte->rte_desc);
-#else
-  writer->writeOptionalTextElement("name", QString::fromUtf8(rte->rte_name));
-  writer->writeOptionalTextElement("desc", QString::fromUtf8(rte->rte_desc));
-#endif
+
   if (rte->rte_num) {
     writer->writeTextElement("number", QString::number(rte->rte_num));
   }
@@ -1626,11 +1618,7 @@ gpx_track_disp(const Waypoint* waypointp)
   /* GPX doesn't require a name on output, so if we made one up
    * on input, we might as well say nothing.
    */
-#if NEW_STRINGS 
   QString oname;
-#else
-  const char* oname;
-#endif
   oname = global_opts.synthesize_shortnames ?
           mkshort_from_wpt(mkshort_handle, waypointp) :
           waypointp->shortname;
@@ -1693,11 +1681,7 @@ gpx_route_hdr(const route_head* rte)
 static void
 gpx_route_disp(const Waypoint* waypointp)
 {
-#if NEW_STRINGS 
   QString oname;
-#else
-  const char* oname;
-#endif
   fs_xml* fs_gpx;
   writer->writeStartElement("rtept");
   writer->writeAttribute("lat", toString(waypointp->latitude));
index 2c13d0794cc0f7f07660e0e42304797ad92e3473..5184409fed18bbdde0cbefe5ff2cc63611515703 100644 (file)
@@ -416,16 +416,10 @@ gtc_crs_hdr(const route_head* rte)
   gtc_lap_start(NULL);
   gtc_new_study_lap(rte);
   route_disp(rte, gtc_study_lap);
-#if NEW_STRINGS 
+
   if (!rte->rte_name.isEmpty()) {
     QString name = rte->rte_name.left(GTC_MAX_NAME_LEN);
     gtc_write_xml(0, QString("<Name>%1</Name>\n").arg(name));
-#else
-  if (rte->rte_name) {
-    char* name = xstrndup(rte->rte_name, GTC_MAX_NAME_LEN);
-    gtc_write_xml(0, "<Name>%s</Name>\n", name);
-    xfree(name);
-#endif
   } else {
     gtc_write_xml(0, "<Name>New Course</Name>\n");
   }
@@ -528,38 +522,21 @@ gtc_trk_utc(xg_string args, const QXmlStreamAttributes*)
 void
 gtc_trk_lat(xg_string args, const QXmlStreamAttributes*)
 {
-#if NEW_STRINGS
   wpt_tmp->latitude = args.toDouble();
-#else
-  wpt_tmp->latitude = atof(args);
-#endif
 }
 
 void
 gtc_trk_long(xg_string args, const QXmlStreamAttributes*)
 {
-#if NEW_STRINGS
   wpt_tmp->longitude = args.toDouble();
-#else
-  wpt_tmp->longitude = atof(args);
-#endif
 }
 
-#if NEW_STRINGS
 void
 gtc_trk_alt(xg_string args, const QXmlStreamAttributes*)
 {
   wpt_tmp->altitude = args.toDouble();
 }
-#else
-void
-gtc_trk_alt(xg_string args, const QXmlStreamAttributes*)
-{
-  wpt_tmp->altitude = atof(args);
-}
-#endif
 
-#if NEW_STRINGS
 void gtc_trk_dist(const QString& args, const QXmlStreamAttributes*)
 {
   wpt_tmp->odometer_distance = args.toDouble();
@@ -572,59 +549,21 @@ void gtc_trk_cad(const QString& args, const QXmlStreamAttributes*)
 {
   wpt_tmp->cadence = args.toDouble();
 }
-#else
-void
-gtc_trk_dist(xg_string args, const QXmlStreamAttributes*)
-{
-  wpt_tmp->odometer_distance = atof(args);
-}
-
-void
-gtc_trk_hr(xg_string args, const QXmlStreamAttributes*)
-{
-  wpt_tmp->heartrate = atoi(args);
-}
 
-void
-gtc_trk_cad(xg_string args, const QXmlStreamAttributes*)
-{
-  wpt_tmp->cadence = atoi(args);
-}
-#endif
-
-#if NEW_STRINGS
 void
 gtc_trk_pwr(xg_string args, const QXmlStreamAttributes*)
 {
   wpt_tmp->power = args.toDouble();
 }
-#else
-void
-gtc_trk_pwr(xg_string args, const QXmlStreamAttributes*)
-{
-  wpt_tmp->power = atof(args);
-}
-#endif
 
 void
-#if NEW_STRINGS
 gtc_trk_spd(xg_string args, const QXmlStreamAttributes*)
 {
   WAYPT_SET(wpt_tmp, speed, args.toDouble());
 }
-#else
-gtc_trk_spd(xg_string args, const QXmlStreamAttributes*)
-{
-  WAYPT_SET(wpt_tmp, speed, atof(args));
-}
-#endif
 
 void
-#if NEW_STRINGS
 gtc_wpt_crs_s(const QString& args, const QXmlStreamAttributes*)
-#else
-gtc_wpt_crs_s(const char*, const QXmlStreamAttributes* unusedattrs)
-#endif
 {
   wpt_tmp = new Waypoint;
 }
@@ -663,7 +602,6 @@ gtc_wpt_pnt_e(xg_string args, const QXmlStreamAttributes*)
   wpt_tmp = NULL;
 }
 
-#if NEW_STRINGS
 void gtc_wpt_ident(const QString& args, const QXmlStreamAttributes*)
 {
   wpt_tmp->shortname = (args);
@@ -686,39 +624,6 @@ void gtc_wpt_notes(const QString& args, const QXmlStreamAttributes*)
 {
   wpt_tmp->description = args;
 }
-#else
-void
-gtc_wpt_ident(xg_string args, const QXmlStreamAttributes*)
-{
-  wpt_tmp->shortname = args;
-  /* Set also as notes for compatibility with garmin usb format */
-  wpt_tmp->notes = args;
-}
-
-void
-gtc_wpt_lat(xg_string args, const QXmlStreamAttributes*)
-{
-  wpt_tmp->latitude = atof(args);
-}
-
-void
-gtc_wpt_long(xg_string args, const QXmlStreamAttributes*)
-{
-  wpt_tmp->longitude = atof(args);
-}
-
-void
-gtc_wpt_icon(xg_string args, const QXmlStreamAttributes*)
-{
-  wpt_tmp->icon_descr = args;
-}
-
-void
-gtc_wpt_notes(xg_string args, const QXmlStreamAttributes*)
-{
-  wpt_tmp->description = args;
-}
-#endif
 
 ff_vecs_t gtc_vecs = {
   ff_type_file,
index 829fba0f9cd66b36905d6b1f87e2bb42d114b406..a30157bdfd022a7a072791ee1161a07eab328dac 100644 (file)
@@ -735,10 +735,9 @@ humminbird_write_waypoint(const Waypoint* wpt)
   be_write32(&hum.north, si_round(north));
 
   QString name;
-// NEW_STRING - remove extra ctor below.
   name = (global_opts.synthesize_shortnames)
          ? mkshort_from_wpt(wptname_sh, wpt)
-         : mkshort(wptname_sh, QString(wpt->shortname));
+         : mkshort(wptname_sh, wpt->shortname);
   memset(&hum.name, 0, sizeof(hum.name));
   memcpy(&hum.name, CSTR(name), name.length());
 
@@ -765,8 +764,7 @@ humminbird_track_head(const route_head* trk)
     trk_head = (humminbird_trk_header_t*) xcalloc(1, sizeof(humminbird_trk_header_t));
     trk_points = (humminbird_trk_point_t*) xcalloc(max_points, sizeof(humminbird_trk_point_t));
 
-// NEW_STRING: remove speare ctor below.
-    name = mkshort(trkname_sh, QString(trk->rte_name));
+    name = mkshort(trkname_sh, trk->rte_name);
     strncpy(trk_head->name, CSTR(name), sizeof(trk_head->name)-1);
     be_write16(&trk_head->trk_num, trk->rte_num);
   }
index 19a98a92c1379146bb9bd6fc2fd0c3ac46d7a823..6430237bbf8a4e5fc47fa8c596568fd0aa86f7fc 100644 (file)
@@ -1176,12 +1176,10 @@ void kml_gc_make_balloonstyle(void)
 }
 
 static
-char*
+QString
 kml_lookup_gc_icon(const Waypoint* waypointp)
 {
   const char* icon;
-  char* rb;
-
   /* This could be done so much better in C99 with designated
    * initializers...
    */
@@ -1230,8 +1228,7 @@ kml_lookup_gc_icon(const Waypoint* waypointp)
     break;
   }
 
-  xasprintf(&rb, "http://www.geocaching.com/images/kml/%s", icon);
-  return rb;
+  return QString("http://www.geocaching.com/images/kml/%1").arg(icon);
 }
 
 static const
@@ -1394,7 +1391,6 @@ static void kml_write_cdata_element(const QString& name, const QString& value)
 
 static void kml_geocache_pr(const Waypoint* waypointp)
 {
-  char* is;
   const char* issues = "";
 
   writer->writeStartElement("Placemark");
@@ -1416,10 +1412,10 @@ static void kml_geocache_pr(const Waypoint* waypointp)
   }
 
   writer->writeTextElement("styleUrl", "#geocache");
-  is = kml_lookup_gc_icon(waypointp);
   writer->writeStartElement("Style");
   writer->writeStartElement("IconStyle");
   writer->writeStartElement("Icon");
+  QString is = kml_lookup_gc_icon(waypointp);
   writer->writeTextElement("href", is);
   writer->writeEndElement(); // Close Icon tag
   writer->writeEndElement(); // Close IconStyle tag
@@ -1474,8 +1470,6 @@ static void kml_geocache_pr(const Waypoint* waypointp)
 
   writer->writeEndElement(); // Close Point tag
   writer->writeEndElement(); // Close Placemark tag
-
-  xfree(is);
 }
 
 /*
index 33a8b1f7836fbd1ee4ffabbd82461d260d24db27..55310654d72502b00ca60d596885181e5d404b12 100644 (file)
@@ -1382,17 +1382,11 @@ mag_waypt_pr(const Waypoint* waypointp)
   if (get_cache_icon(waypointp)) {
     icon_token = mag_find_token_from_descr(get_cache_icon(waypointp));
   }
-#if NEW_STRINGS
+
   QString isrc = waypointp->notes.isEmpty() ? waypointp->description : waypointp->notes;
   QString owpt = global_opts.synthesize_shortnames ?
          mkshort_from_wpt(mkshort_handle, waypointp) : waypointp->shortname;
   QString odesc = isrc;
-#else
-  String isrc = waypointp->notes ? waypointp->notes : waypointp->description;
-  char* owpt = global_opts.synthesize_shortnames ?
-         mkshort_from_wpt(mkshort_handle, waypointp) : waypointp->shortname;
-  char* odesc = isrc ? isrc : (char*)"";
-#endif
   owpt = mag_cleanse(CSTRc(owpt));
 
   if (global_opts.smart_icons &&
@@ -1409,11 +1403,7 @@ mag_waypt_pr(const Waypoint* waypointp)
    * to deliver turn-by-turn popups for street routing) allow a
    * cap on the comments delivered so we leave space for it to route.
    */
-#if NEW_STRINGS
   if (!odesc.isEmpty() && (wptcmtcnt++ >= wptcmtcnt_max)) {
-#else
-  if (odesc && /* !is_file && */ (wptcmtcnt++ >= wptcmtcnt_max)) {
-#endif
     odesc[0] = 0;
   }
 
@@ -1427,11 +1417,6 @@ mag_waypt_pr(const Waypoint* waypointp)
           CSTRc(odesc),
           icon_token.toUtf8().data());
   mag_writemsg(obuf);
-#if NEW_STRINGS
-#else
-  xfree(owpt);
-  xfree(odesc);
-#endif
 
   if (!is_file) {
     if (mag_error) {
@@ -1553,20 +1538,8 @@ mag_route_trl(const route_head* rte)
     } else {
       pbuff = buff2;
     }
-#if NEW_STRINGS
-// TODO: figure out what this code is trying to do.
-    sprintf(pbuff, "%s,%s", CSTR(waypointp->shortname), icon_token.toUtf8().data());
-#else
-    owpt = waypointp->shortname;
-    if (strlen(owpt) > sizeof(buff1) - 3) {
-      owpt[sizeof(buff1) - 3] = 0;
-    }
-    owpt = mag_cleanse(owpt);
-
-    sprintf(pbuff, "%s,%s", owpt, icon_token.toUtf8().data());
-
-    xfree(owpt);
-#endif
+    // Write name, icon tuple into alternating buff1/buff2 buffer.
+    sprintf(pbuff, "%s,%s", CSTR(waypointp->shortname), CSTR(icon_token));
 
     if ((tmp == &rte->waypoint_list) || ((i % 2) == 0)) {
       char expbuf[1024];
@@ -1574,11 +1547,7 @@ mag_route_trl(const route_head* rte)
       expbuf[0] = 0;
       if (explorist) {
         snprintf(expbuf, sizeof(expbuf), "%s,",
-#if NEW_STRINGS
                  CSTRc(rte->rte_name));
-#else
-                 rte->rte_name ? CSTRc(rte->rte_name) : "");
-#endif
       }
 
       sprintf(obuff, "PMGNRTE,%d,%d,c,%d,%s%s,%s",
index a13d735bf469e9d92e2b94f26988b59dad0fbf3e..6f114cadfe702e6dbe078703ff970036df464665 100644 (file)
@@ -298,27 +298,14 @@ mapsend_waypt_pr(const Waypoint* waypointp)
   QString tmp1 = mkshort(wpt_handle, sn);
   gbfputpstr(tmp1, mapsend_file_out);
 
-#if NEW_STRINGS
+  // This is funny looking to ensure that no more than 30 bytes
+  // get written to the file.
   c = waypointp->description.length();
   if (c > 30) {
     c = 30;
   }
   gbfputc(c, mapsend_file_out);
   gbfwrite(CSTR(waypointp->description), 1, c, mapsend_file_out);
-#else
-  char* tmp = waypointp->description;
-  if (tmp) {
-    c = strlen(tmp);
-  } else {
-    c = 0;
-  }
-
-  if (c > 30) {
-    c = 30;
-  }
-  gbfputc(c, mapsend_file_out);
-  gbfwrite(tmp, 1, c, mapsend_file_out);
-#endif
 
   /* #, icon, status */
   gbfputint32(++cnt, mapsend_file_out);
@@ -393,13 +380,7 @@ mapsend_route_disp(const Waypoint* waypointp)
   route_wp_count++;
 
   /* waypoint name */
-#if NEW_STRINGS
-  c = waypointp->shortname.length();
-#else
-  c = waypointp->shortname ? strlen(waypointp->shortname) : 0;
-#endif
-  gbfwrite(&c, 1, 1, mapsend_file_out);
-  gbfwrite(CSTRc(waypointp->shortname), 1, c, mapsend_file_out);
+  gbfputpstr(waypointp->shortname, mapsend_file_out);
 
   /* waypoint number */
   gbfputint32(route_wp_count, mapsend_file_out);
@@ -457,21 +438,8 @@ void mapsend_track_hdr(const route_head* trk)
   hdr.ms_version[1] = verstring[1];
 
   gbfwrite(&hdr, sizeof(hdr), 1, mapsend_file_out);
-#if NEW_STRINGS
   QString tname = trk->rte_name.isEmpty() ? "Track" : trk->rte_name;
   gbfputpstr(tname, mapsend_file_out);
-#else
-  /* track name */
-  char* tname;
-  if (!trk->rte_name) {
-    tname = xstrdup("Track");
-  } else {
-    tname = xstrdup(trk->rte_name);
-  }
-  gbfputpstr(tname, mapsend_file_out);
-
-  xfree(tname);
-#endif
 
   /* total nodes (waypoints) this track */
   i = 0;
index 573ab8b0bf6f9de1a3c2ad740d6b8a08d8433a15..1fdf6c02a22bbb87ca6376061f80948483ce7899 100644 (file)
@@ -752,13 +752,13 @@ static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm)
   if (global_opts.masked_objective& TRKDATAMASK && (trk_head == NULL || (mtk_info.track_event & MTK_EVT_START))) {
     char spds[50];
     trk_head = route_head_alloc();
-    xasprintf(&trk_head->rte_name, "track-%d", 1+track_count());
+    trk_head->rte_name = QString("track-%1").arg(1 + track_count());
 
     spds[0] = '\0';
     if (mtk_info.speed > 0) {
       sprintf(spds, " when moving above %.0f km/h", mtk_info.speed/10.);
     }
-    xasprintf(&trk_head->rte_desc, "Log every %.0f sec, %.0f m%s"
+    trk_head->rte_desc = QString().sprintf("Log every %.0f sec, %.0f m%s"
               , mtk_info.period/10., mtk_info.distance/10., spds);
     track_add_head(trk_head);
   }
index 66c3faff5c5ea4175c581fc8ff045220fa24561e..c23b937c0d69a10aac3aec1ec5310a4b28ef020e 100644 (file)
@@ -433,10 +433,9 @@ osm_feature_ikey(const char* key)
 }
 
 
-static char*
+static QString
 osm_feature_symbol(const int ikey, const char* value)
 {
-  char* result;
   char buff[128];
   QString key;
 
@@ -444,12 +443,13 @@ osm_feature_symbol(const int ikey, const char* value)
   strncpy(&buff[1], value, sizeof(buff) - 1);
 
   key = QString::fromUtf8(buff);
+
+  QString result;
   if (values.contains(key)) {
-    result = xstrdup(values.value(key)->icon);
+    result = values.value(key)->icon;
   } else {
-    xasprintf(&result, "%s:%s", osm_features[ikey], value);
+    result = QString("%1:%2").arg(osm_features[ikey]).arg(value);
   }
-
   return result;
 }
 
@@ -538,11 +538,7 @@ osm_node_tag(xg_string args, const QXmlStreamAttributes* attrv)
   } else if (strcmp(key, "name:en") == 0) {
     wpt->shortname = str;
   } else if ((ikey = osm_feature_ikey(key)) >= 0) {
-    char* id = osm_feature_symbol(ikey, value);
-    wpt->icon_descr = id;
-    if (id) {
-      xfree(id);
-    }
+    wpt->icon_descr = osm_feature_symbol(ikey, value);
   } else if (strcmp(key, "note") == 0) {
     if (wpt->notes.isEmpty()) {
       wpt->notes = str;
@@ -827,11 +823,7 @@ osm_waypt_disp(const Waypoint* wpt)
   }
 
   osm_write_tag("name", wpt->shortname);
-#if NEW_STRINGS
   osm_write_tag("note", (wpt->notes.isEmpty()) ? wpt->description : wpt->notes);
-#else
-  osm_write_tag("note", (wpt->notes) ? wpt->notes : wpt->description);
-#endif
   if (!wpt->icon_descr.isNull()) {
     osm_disp_feature(wpt);
   }
index a2cdb7cd16f1ef96c52c40518b84c7fffd67a4f7..e68e210cedaf7897a00e070e6c4f9dd4bd00f3f8 100644 (file)
@@ -364,8 +364,8 @@ pcx_track_hdr(const route_head* trk)
 
   route_ctr++;
   snprintf(buff, sizeof(buff)-1, "Trk%03d", route_ctr);
-// NEW_STRINGS - remove extr ctor below.
-  QString name = mkshort(mkshort_handle2, (trk->rte_name != NULL) ? QString(trk->rte_name) : buff);
+
+  QString name = mkshort(mkshort_handle2, trk->rte_name.isEmpty() ?  buff : trk->rte_name);
   /* Carto Exploreur (popular in France) chokes on trackname headers,
    * so provide option to supppress these.
    */
index aa56215ff8962c2f4dc23c66a1ce87e44f7ed03f..7055e28fd6c5c278374d6d7233a08acd9132f164 100644 (file)
@@ -500,21 +500,12 @@ psit_routehdr_w(gbfile* psit_file, const route_head* rte)
     }
 
     /* route name */
-#if NEW_STRINGS
     if (rte->rte_name.isEmpty()) {
       sprintf(hdr, "Route%04x", (unsigned) uniqueValue);
       rname = xstrdup(hdr);
     } else {
       rname = xstrdup(rte->rte_name);
     }
-#else
-    if (!rte->rte_name) {
-      sprintf(hdr, "Route%04x", (unsigned) uniqueValue);
-      rname = xstrdup(hdr);
-    } else {
-      rname = xstrdup(rte->rte_name);
-    }
-#endif
     /* check for psitrex comment sign; replace with '$' */
     while ((c = strchr(rname, '#'))) {
       *c = '$';
@@ -667,11 +658,7 @@ psit_trackhdr_w(gbfile* psit_file, const route_head* trk)
       }
 
       /* track name */
-#if NEW_STRINGS
       if (trk->rte_name.isEmpty()) {
-#else
-      if (!trk->rte_name) {
-#endif
         sprintf(hdr, "Track%04x", (unsigned) uniqueValue);
         tname = xstrdup(hdr);
       } else {
index 59030b4e6e512fdc266d72c0f444f18335eea8c9..081c06b8d0a96e8f9da9d026e9e08e1fb5d562e5 100644 (file)
@@ -664,7 +664,7 @@ make_trackpoint(struct read_state* st, double lat, double lon, double alt)
 {
   Waypoint* wpt = new Waypoint;
 
-  xasprintf(&wpt->shortname, "TP%04d", ++st->tpn);
+  wpt->shortname = QString().sprintf("TP%04d", ++st->tpn);
 
   wpt->latitude       = lat;
   wpt->longitude      = lon;
@@ -1529,8 +1529,8 @@ static void miniHomer_get_poi()
       ECEF_to_LLA(ecef_x, ecef_y, ecef_z, &lat, &lng, &alt);
 
       wpt = new Waypoint;
-      xasprintf(&wpt->shortname, "POI_%s", poinames[poi]);
-      xasprintf(&wpt->description, "miniHomer points to this coordinates if the %s symbol is on", poinames[poi]);
+      wpt->shortname      = QString().sprintf("POI_%s", poinames[poi]);
+      wpt->description    = QString().sprintf("miniHomer points to this coordinates if the %s symbol is on", poinames[poi]);
       wpt->latitude       = lat;
       wpt->longitude      = lng;
       wpt->altitude       = alt;
index c1b34a405617c51467b47eb184f738ca9baa8e1c..3a0e4148d404582194dc4d6fe60f2a56d9227d17 100644 (file)
@@ -216,7 +216,7 @@ finalize_tracks(void)
       trackno++;
       if (rte_name != NULL) {
         if (trackno > 1) {
-          xasprintf(&track->rte_name, "%s (%d)", CSTR(rte_name), trackno);
+          track->rte_name = QString("%1 (%2)").arg(rte_name).arg(trackno);
         } else {
           track->rte_name = rte_name;
         }
@@ -302,7 +302,7 @@ parse_point(char* line)
         break;
       case 3:
         WAYPT_SET(wpt, proximity, atof(str));
-        xasprintf(&wpt->notes, "Alarm point: radius=%s", str);
+        wpt->notes = QString().sprintf("Alarm point: radius=%s", str);
         break;
       }
       break;
@@ -658,8 +658,7 @@ route_disp_wpt_cb(const Waypoint* wpt)
     if (global_opts.synthesize_shortnames) {
       sn = mkshort_from_wpt(short_h, wpt);
     } else {
-// NEW_STRINGS: eliminate extra ctor below.
-      sn = mkshort(short_h, QString(wpt->shortname));
+      sn = mkshort(short_h, wpt->shortname);
     }
     gbfprintf(fout, "\"WP\",\"%s\",%.8lf,%.8lf,%.f\n",
               CSTR(sn), wpt->latitude, wpt->longitude, ALT(wpt));
index f40e2ba07722dd6bfaea22a8ce906f240a656adb..18a65fae250eb9587e38f6dcf6658242f4ad73b5 100644 (file)
@@ -213,8 +213,7 @@ tiger_disp(const Waypoint* wpt)
   gbfprintf(file_out, "%f,%f:%s", lon, lat, pin.toUtf8().data());
   if (!nolabels) {
     QString temp;
-// NEW_STRINGS - eliminate extr ctor below.
-    QString desc = csv_stringclean(QString(wpt->description), ":");
+    QString desc = csv_stringclean(wpt->description, ":");
     if (global_opts.synthesize_shortnames) {
       temp = desc;
       desc = mkshort(mkshort_whandle, desc);
index ece38cc0431c345c2af5f9c6848d9cdc8c07c231..d28d36e117787f0b90b95530c1cf4bfe6c51fc0f 100644 (file)
@@ -277,7 +277,7 @@ xasprintf(char** strp, const char* fmt, ...)
 
   return res;
 }
-#if NEW_STRINGS
+
 int
 xasprintf(QString* strp, const char* fmt, ...)
 {
@@ -292,7 +292,6 @@ xasprintf(QString* strp, const char* fmt, ...)
 
   return res;
 }
-#endif
 
 int
 xvasprintf(char** strp, const char* fmt, va_list ap)